﻿//using SixLabors.Fonts;
using SixLabors.Fonts;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Drawing.Processing;
using SixLabors.ImageSharp.Processing;

using System;
using System.Drawing.Text;

// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");
// 读取图像文件
using (Image image = Image.Load($@"E:\James.Liu\Projects\1.jpg"))
{
    // 定义水印文本和字体
    string watermarkText = "Watermark Text";
    Font font = SystemFonts.CreateFont("Arial", 36);

    var textSize = TextMeasurer.MeasureSize(watermarkText, new TextOptions(font));
    var textX = (image.Width - textSize.Width) / 2;
    var textY = (image.Height - textSize.Height) / 2;

    // 在图像上绘制水印文本
    image.Mutate(x => x.DrawText(watermarkText, font, Color.Red, new PointF(textY, textY)));

    // 保存带有水印的图像
    image.Save($@"E:\James.Liu\Projects\1_Watermark.jpg");
}



//// 创建 InstalledFontCollection 对象
//InstalledFontCollection installedFontCollection = new InstalledFontCollection();

//// 获取系统中已安装的所有字体
//var fontFamilies = installedFontCollection.Families;

//// 输出所有已安装的字体名称
//foreach (var item in fontFamilies)
//{
//    Console.WriteLine(item.Name);
//}
//Console.ReadKey();